# coding: utf-8

import pandas as pd

wutandianhao='物探点号'
lianjiedianhao='连接点号'
liuxiang='流向'
plid='PLID'
def getPTable():
    #打开excel文件
    df =pd.read_excel("HS-汕尾项目总库成果表 - v1.xlsx")
    print(df)

    #tip： 根据流向筛选数据
    df_zhengxiang=df[df[liuxiang]==0]
    #tip：拼凑plid
    df_zhengxiang[plid]=df_zhengxiang[wutandianhao]+df_zhengxiang[lianjiedianhao]
    print(df_zhengxiang)

    #tip： 根据流向筛选数据
    df_fanxiang=df[df[liuxiang]==1]
    #tip： 拼凑plid，并反向
    df_fanxiang[plid]=df_fanxiang[lianjiedianhao]+df_fanxiang[wutandianhao]
    print(df_fanxiang)

    df_result=pd.concat([df_zhengxiang,df_fanxiang])
    # df_zhengxiang.append(df_fanxiang)
    print(df_result)
    print(df_result.drop_duplicates([plid]))

    df_result.drop_duplicates([plid]).to_excel("HS-汕尾项目总库成果表 - 线表-导出1.xlsx")
    # for row in df.itertuples():
    #     # print(row)
    #     if(getattr(row, liuxiang)==0):
    #         print(row)


if __name__ == '__main__':
    getPTable()